﻿#include "pagejump.h"
#include "ui_pagejump.h"

PageJump::PageJump(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PageJump)
{
    ui->setupUi(this);

    login = new LoginWidget;
    registers = new RegisterWidget;
    mainwidget = new MainWidget;
    setting = new SettingWidget;
    record = new RecordWidget;
    password = new PasswordWidget;
    serial = new SerialWindow;

    //主界面发出的信号
    connect(mainwidget, &MainWidget::goSettingWidget, this, &PageJump::showSetting);
    connect(mainwidget, &MainWidget::goRecordWidget, this, &PageJump::showRecord);
    connect(mainwidget, &MainWidget::goPasswordWidget, this, &PageJump::showPassword);
    connect(mainwidget, &MainWidget::goSerialWindow, this, &PageJump::showSerial);

    //登录界面发出的信号
    connect(login, &LoginWidget::goRegisterWidget, this, &PageJump::showRegister);
    connect(login, &LoginWidget::goMainWidget, this, &PageJump::showMain);

    //注册界面发出的信号
    connect(registers, &RegisterWidget::goLoginWidget, this, &PageJump::showLogin);

    //设置界面发出的信号
    connect(setting, &SettingWidget::goMainWidget, this, &PageJump::showMain);
    connect(setting, &SettingWidget::goRecordWidget, this, &PageJump::showRecord);
    connect(setting, &SettingWidget::goPasswordWidget, this, &PageJump::showPassword);
    connect(setting, &SettingWidget::goSerialWindow, this, &PageJump::showSerial);

    //历史记录界面发出的信号
    connect(record, &RecordWidget::goMainWidget, this, &PageJump::showMain);
    connect(record, &RecordWidget::goSettingWidget, this, &PageJump::showSetting);
    connect(record, &RecordWidget::goPasswordWidget, this, &PageJump::showPassword);
    connect(record, &RecordWidget::goSerialWindow, this, &PageJump::showSerial);

    //设置密码界面发出的信号
    connect(password, &PasswordWidget::goMainWidget, this, &PageJump::showMain);
    connect(password, &PasswordWidget::goSettingWidget, this, &PageJump::showSetting);
    connect(password, &PasswordWidget::goRecordWidget, this, &PageJump::showRecord);
    connect(password, &PasswordWidget::goSerialWindow, this, &PageJump::showSerial);

    //串口界面发出的信号
    connect(serial, &SerialWindow::goMainWidget, this, &PageJump::showMain);
    connect(serial, &SerialWindow::goSettingWidget, this, &PageJump::showSetting);
    connect(serial, &SerialWindow::goRecordWidget, this, &PageJump::showRecord);
    connect(serial, &SerialWindow::goPasswordWidget, this, &PageJump::showPassword);
}

PageJump::~PageJump()
{
    delete ui;
}

void PageJump::show()
{
    showLogin();
}

void PageJump::showLogin()
{
    login->show();
}

void PageJump::showRegister()
{
    registers->show();
}

void PageJump::showMain()
{
    mainwidget->show();
}

void PageJump::showSetting()
{
    setting->show();
}

void PageJump::showRecord()
{
    record->show();
}

void PageJump::showPassword()
{
    password->show();
}

void PageJump::showSerial()
{
    serial->show();
}










